package com.spzx.product.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.product.api.RemoteProductService;
import com.spzx.product.api.model.ProductSku;
import com.spzx.product.vo.SkuPriceVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.List;

/**
 * 用户服务降级处理
 *
 * @author spzx
 */
@Slf4j
//@Component
public class RemoteProductFallbackFactory implements FallbackFactory<RemoteProductService> {

    @Override
    public RemoteProductService create(Throwable cause) {
        log.error("获取商品SKU详情失败:{}", cause.getMessage());
        return new RemoteProductService() {
            @Override
            public R<ProductSku> getProductSku(Long skuId, String header) {
                return null;
            }

            @Override
            public R<List<SkuPriceVo>> getSkuPriceList(List<Long> skuIdList, String source) {
                return R.fail("批量获取商品价格失败" + cause.getMessage());
            }

            @Override
            public R<SkuPriceVo> getSkuPrice(Long skuId, String source) {
                return null;
            }


        };
    }
}
